package com.zcxy360.sandtable.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zcxy360.sandtable.domain.UnitProblem;
import com.zcxy360.sandtable.domain.UnitProblemExample;
import com.zcxy360.sandtable.domain.UnitProblemExample.Criteria;
import com.zcxy360.sandtable.domain.UnitProblemMapper;

@Transactional
@Service
public class UnitProblemService {

	@Autowired
	private UnitProblemMapper unitProblemMapper;

	public Object list(UnitProblem unitProblem) {
		UnitProblemExample ex = new UnitProblemExample();
		Criteria or = ex.or();
		if (unitProblem.getCourseId() != null) {
			or.andCourseIdEqualTo(unitProblem.getCourseId());
		}
		if (unitProblem.getUserId() != null) {
			or.andUserIdEqualTo(unitProblem.getUserId());
		}
		if (unitProblem.getUnitId() != null) {
			or.andUnitIdEqualTo(unitProblem.getUnitId());
		}
		if (unitProblem.getVproblemId() != null) {
			or.andVproblemIdEqualTo(unitProblem.getVproblemId());
		}
		return unitProblemMapper.selectByExample(ex);
	}

}
